package world.snowcrystal.nova.ai;

import com.zhipu.oapi.ClientV4;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import world.snowcrystal.nova.ai.Entity.ChatCompletionRequestFactory;

import java.util.concurrent.TimeUnit;

@Configuration
@EnableConfigurationProperties(AIProperties.class)
public class AIConfiguration {

    private final AIProperties aiProperties;

    public AIConfiguration(AIProperties aiProperties) {
        this.aiProperties = aiProperties;
    }


    @Bean
    public ChatCompletionRequestFactory chatCompletionRequestFactory() {
        return new ChatCompletionRequestFactory();
    }

    @Bean
    public ClientV4 clientV4() {
        return new ClientV4.Builder(aiProperties.getApiSecretKey())
                .networkConfig(60, 1000,1000, 1000, TimeUnit.SECONDS)
                .build();
    }


}




